<?php

	$site_root = "";
	require_once ($site_root . "common/PinSQL.obj");
	$pinSQL = new PinSQL();
	
	$username = $_POST['husern'];
	$password = $_POST['hpassword'];
	$firstname = $_POST['hfirstname'];
	$lastname = $_POST['hlastname'];
	$email = $_POST['hemail'];
	
	$pinSQL->Query("INSERT INTO members
	(username, password, firstname, lastname, email)
	VALUES('$username', '$password', '$firstname', '$lastname', '$email')
	");
	
	$pinSQL->Query("SELECT * FROM members WHERE username='$username'");
	$row = $pinSQL->FetchNextRow();
	$id = $row['id'];
	
	$pinSQL->Query("INSERT INTO memberdata 
	(id)
	VALUES ($id)");
	
	
	$pinSQL->Query("INSERT INTO privacy 
	(id)
	VALUES ($id)");
	

	//create the userData folder for this new user
	mkdir("members/userData/$username", 0755);
	mkdir("members/userData/$username/music", 0755);
	mkdir("members/userData/$username/pictures", 0755);
	mkdir("members/userData/$username/videos", 0755);
	mkdir("members/userData/$username/games", 0755);	
	
	
	$pinSQL->Query("INSERT INTO messages
	(fromuser, touser, subject, message)
	VALUES('PinProject', '$username', 'Welcome!', 'Welcome to the Pin Project!  We hope you enjoy your stay.  If you have any questions, don\'t hesitate to send a message to one of the admins, ilikemonkeys111 or david.  Thanks!')");

	mysql_query("INSERT INTO activity
	(event_type, by_user, url_1)
	VALUES('new-user', '$username',
	'/members/frame.php?page=profile&user=$username') ")
	or die(mysql_error());

	$pinSQL->Close();  //zip it up
	
?>

<div class="head">Congratulations</div>

<p /><div class="subhead">Account Created Successfully</div>

<p />Congratulations, <?php echo (($firstname) ? $firstname : $username); ?>! You have successfully joined The Pin Project.
<br />Let's get started!

<p /><div class="subhead">Login Now</div>

<p />
<form name="login" method="post" action="checkLogin.php">
	<table>
		<tr>
			<td>Username:</td>
			<td><input name="username" value="<?php echo $username; ?>" class="loginform" type="text" size="12" /></td>
		</tr>
		
		<tr>
			<td>Password:</td>
			<td><input name="password" class="loginform" type="password" size="12" /></td>
		</tr>
		
		<tr>
			<td></td>
			<td><input class="loginform" type="submit" value="Login" /></td>
	</table>
</form>




